import XSvg from "../svgs/X"

import {MdHomeFilled} from "react-icons/md"
import {IoNotifications} from "react-icons/io5"
import {FaUser} from "react-icons/fa"
import {Link} from "react-router-dom"
import {BiLogOut} from "react-icons/bi"
import {useMutation, useQuery, useQueryClient} from "@tanstack/reqct-query"
import toast from  "react-hot-toast"

const Sidebar = () => {
    const queryClient = useQueryClient()
    const {mutate: logout} = useMutation({
        mutationFn: async() => {
            try {
                const res = await fetch("/api/auth/logout", {
                    method: "POST",
                })

                const data = await res.json()

                if (!res.ok) {
                    throw new Error(data.error || "Something went wrong")
                }
            } catch(error) {
                throw new Error("Error in component Sidebar: " + error)
            }
        },

        onSuccess: () => {
            queryClient.invalidateQueries({
                queryKey: ["authUser"]
            })
        },

        onError: () => {
            toast.error("Logout failed")
        },
    })

    const {data: authUser} = useQuery({queryKey: ["authUser"]})

    // TODO: fix this comp
    return (
        <div>
        </div>
    )

}

export default Sidebar;